package fr.insta.browser.home;

import java.util.List;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import fr.insta.browser.domain.StateOnStart;
import fr.insta.browser.service.tab.ITabService;
import fr.insta.browser.view.frame.ToolsFrame;
import fr.insta.webview.object.IWebObject;
import fr.insta.webview.service.ServiceWebObject;

/**
 * <p>SetUpHomePanel class.</p>
 *
 * @author Maarek
 * @version $Id: $Id
 */
public class SetUpHomePanel extends JPanel 
{
	private JTextField txt_currentHome;
	private JFrame parentFrame;
	private JLabel lab_currentHome;
	private JButton btnOk;
	private JButton btnAnnuler;
	private JButton btnPageCourante;
	private JButton btnDefaultHome;

	public enum SetUpHomeActions { SAVE_CHANGES, CANCEL, CURRENT_PAGE, SET_DEFAULT_HOME; }

	/**
	 * Create the panel.
	 *
	 * @param frameParent a {@link javax.swing.JFrame} object.
	 * @param _tabService a {@link fr.insta.browser.service.tab.ITabService} object.
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public SetUpHomePanel(ToolsFrame frameParent, ITabService _tabService) 
	{
		this.parentFrame = frameParent;
		setLayout(null);
		
		lab_currentHome = new JLabel("Ma page d'accueil :");
		lab_currentHome.setBounds(38, 42, 124, 14);
		add(lab_currentHome);
		
		txt_currentHome = new JTextField();
		txt_currentHome.setBounds(176, 39, 347, 20);
		add(txt_currentHome);
		txt_currentHome.setText(ServiceWebObject.INSTANCE.unserializeHomepage().get(0).getUrl());
		txt_currentHome.setColumns(10);
		
		btnOk = new JButton("Ok");
		btnOk.addActionListener(new SetUpHomeListener(this, SetUpHomeActions.SAVE_CHANGES, _tabService));
		btnOk.setBounds(331, 188, 89, 37);
		add(btnOk);
		
		btnPageCourante = new JButton("Page courante");
		btnPageCourante.addActionListener(new SetUpHomeListener(this, SetUpHomeActions.CURRENT_PAGE, _tabService));
		btnPageCourante.setBounds(176, 70, 110, 38);
		add(btnPageCourante);
		
		btnDefaultHome = new JButton("Restaurer la page d'accueil par défaut");
		btnDefaultHome.addActionListener(new SetUpHomeListener(this, SetUpHomeActions.SET_DEFAULT_HOME, _tabService));
		btnDefaultHome.setBounds(296, 70, 227, 38);
		add(btnDefaultHome);
		
		btnAnnuler = new JButton("Annuler");
		btnAnnuler.addActionListener(new SetUpHomeListener(this, SetUpHomeActions.CANCEL, _tabService));
		btnAnnuler.setBounds(434, 188, 89, 37);
		add(btnAnnuler);
	}

	/**
	 * <p>Getter for the field <code>parentFrame</code>.</p>
	 *
	 * @return a {@link javax.swing.JFrame} object.
	 */
	public JFrame getParentFrame() {
		return parentFrame;
	}

	/**
	 * <p>Getter for the field <code>txt_currentHome</code>.</p>
	 *
	 * @return a {@link javax.swing.JTextField} object.
	 */
	public JTextField getTxt_currentHome() {
		return txt_currentHome;
	}

	/**
	 * <p>Setter for the field <code>txt_currentHome</code>.</p>
	 *
	 * @param txt_currentHome a {@link javax.swing.JTextField} object.
	 */
	public void setTxt_currentHome(JTextField txt_currentHome) {
		this.txt_currentHome = txt_currentHome;
	}

	/**
	 * <p>Getter for the field <code>lab_currentHome</code>.</p>
	 *
	 * @return a {@link javax.swing.JLabel} object.
	 */
	public JLabel getLab_currentHome() {
		return lab_currentHome;
	}

	/**
	 * <p>Setter for the field <code>lab_currentHome</code>.</p>
	 *
	 * @param lab_currentHome a {@link javax.swing.JLabel} object.
	 */
	public void setLab_currentHome(JLabel lab_currentHome) {
		this.lab_currentHome = lab_currentHome;
	}

	/**
	 * <p>Getter for the field <code>btnOk</code>.</p>
	 *
	 * @return a {@link javax.swing.JButton} object.
	 */
	public JButton getBtnOk() {
		return btnOk;
	}

	/**
	 * <p>Setter for the field <code>btnOk</code>.</p>
	 *
	 * @param btnOk a {@link javax.swing.JButton} object.
	 */
	public void setBtnOk(JButton btnOk) {
		this.btnOk = btnOk;
	}

	/**
	 * <p>Getter for the field <code>btnAnnuler</code>.</p>
	 *
	 * @return a {@link javax.swing.JButton} object.
	 */
	public JButton getBtnAnnuler() {
		return btnAnnuler;
	}

	/**
	 * <p>Setter for the field <code>btnAnnuler</code>.</p>
	 *
	 * @param btnAnnuler a {@link javax.swing.JButton} object.
	 */
	public void setBtnAnnuler(JButton btnAnnuler) {
		this.btnAnnuler = btnAnnuler;
	}

	/**
	 * <p>Getter for the field <code>btnPageCourante</code>.</p>
	 *
	 * @return a {@link javax.swing.JButton} object.
	 */
	public JButton getBtnPageCourante() {
		return btnPageCourante;
	}

	/**
	 * <p>Setter for the field <code>btnPageCourante</code>.</p>
	 *
	 * @param btnPageCourante a {@link javax.swing.JButton} object.
	 */
	public void setBtnPageCourante(JButton btnPageCourante) {
		this.btnPageCourante = btnPageCourante;
	}

	/**
	 * <p>Getter for the field <code>btnDefaultHome</code>.</p>
	 *
	 * @return a {@link javax.swing.JButton} object.
	 */
	public JButton getBtnDefaultHome() {
		return btnDefaultHome;
	}

	/**
	 * <p>Setter for the field <code>btnDefaultHome</code>.</p>
	 *
	 * @param btnDefaultHome a {@link javax.swing.JButton} object.
	 */
	public void setBtnDefaultHome(JButton btnDefaultHome) {
		this.btnDefaultHome = btnDefaultHome;
	}

	
}
